package com.peak.spring.boot.core.repository;

import javax.persistence.EntityManager;

import org.springframework.data.jpa.repository.support.JpaEntityInformation;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import com.peak.spring.boot.api.repository.BaseRepository;

/**
 * 重新实现并得到entityManager
 * 
 * @author Haley Gao
 *
 * @param <T>
 */
public class BaseRepositoryImpl<T> extends SimpleJpaRepository<T, Number> implements BaseRepository<T> {

	private final EntityManager entityManager;

	public BaseRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
		super(domainClass, entityManager);
		this.entityManager = entityManager;
	}

	public BaseRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
		super(entityInformation, entityManager);
		this.entityManager = entityManager;
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}

	@Override
	public Class<T> getEntityClass() {
		return this.getDomainClass();
	}
}
